<template>
	<main-content
		:tableHeight.sync="tableHeight"
		:otherDependenComponents="otherDependenComponents"
	>
		<template slot="query">
			<el-form
				slot="page-search"
				ref="queryData"
				:inline="true"
				label-suffix=":"
				label-width="100px"
			>
				<el-form-item label="德州注单号">
					<el-input
						v-input="{ name: 'num' }"
						clearable
						v-model="queryData.id"
						:placeholder="$t('common.please_enter')"
					/>
				</el-form-item>
				<el-form-item label="三方注单号">
					<el-input
						v-input="{ name: 'num_alp' }"
						clearable
						v-model="queryData.generatedId"
						:placeholder="$t('common.please_enter')"
					/>
				</el-form-item>
				<el-form-item label="会员账号">
					<el-input
						v-input="{ name: 'num_alp' }"
						clearable
						v-model="queryData.playerName"
						:placeholder="$t('common.please_enter')"
						style="width: 150px"
					/>
				</el-form-item>
				<el-form-item
					:label="`会员所属俱乐部ID`"
					prop="userClubId"
					label-width="135px"
				>
					<el-input
						v-model.trim="queryData.userClubId"
						v-input="{ name: 'num' }"
						clearable
						style="width: 130px"
						:placeholder="`${$t('common.please_enter')}`"
					></el-input>
				</el-form-item>
				<el-form-item label="牌桌ID">
					<el-input
						v-input="{ name: 'num_alp' }"
						clearable
						v-model="queryData.tableCode"
						:placeholder="$t('common.please_enter')"
						style="width: 200px"
					/>
				</el-form-item>
				<el-form-item label="牌桌所属俱乐部ID" label-width="135px">
					<el-input
						v-input="{ name: 'num' }"
						clearable
						v-model="queryData.clubId"
						:placeholder="$t('common.please_enter')"
						style="width: 130px"
					/>
				</el-form-item>
				<el-form-item
					:label="`${$t('dxn.card_ables_list.game_name')}`"
					prop="gameTypeList"
				>
					<el-select
						v-model="queryData.gameTypeList"
						clearable
						:placeholder="
							`${$t('dxn.card_ables_list.game_name_placeholder')}`
						"
						multiple
						style="width: 220px"
					>
						<el-option
							v-for="item in gameTypes"
							:key="item.code"
							:label="item.description"
							:value="item.code"
						></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="手牌ID">
					<el-input
						v-input="{ name: 'num_alp' }"
						clearable
						v-model="queryData.handId"
						:placeholder="$t('common.please_enter')"
						style="width: 200px"
					/>
				</el-form-item>
				<el-form-item label="投注时间">
					<el-date-picker
						clearable
						v-model="queryData.dateTime"
						size="medium"
						:picker-options="pickerShortcut2"
						format="yyyy-MM-dd HH:mm:ss"
						type="datetimerange"
						range-separator="-"
						:start-placeholder="$t('common.start_date')"
						:end-placeholder="$t('common.end_date')"
						align="right"
						value-format="timestamp"
						style="width: 430px"
						:default-time="defaultTime"
					></el-date-picker>
				</el-form-item>
				<el-form-item label="结算时间">
					<el-date-picker
						clearable
						v-model="queryData.settlementTime"
						size="medium"
						:picker-options="pickerShortcut2"
						format="yyyy-MM-dd HH:mm:ss"
						type="datetimerange"
						range-separator="-"
						:start-placeholder="$t('common.start_date')"
						:end-placeholder="$t('common.end_date')"
						align="right"
						value-format="timestamp"
						style="width: 430px"
						:default-time="defaultTime"
					></el-date-picker>
				</el-form-item>
				<el-form-item label="注单类型">
					<el-select
						v-model="queryData.parentOrderTypeList"
						clearable
						:placeholder="`${$t('common.select_all')}`"
						multiple
						style="width:240px"
					>
						<el-option
							v-for="item in parentOrderTypeSelect"
							:key="item.code"
							:label="item.description"
							:value="item.code"
						></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="注单子类">
					<el-select
						v-model="queryData.betTypeList"
						clearable
						:placeholder="`${$t('common.select_all')}`"
						multiple
						style="width:240px"
					>
						<el-option
							v-for="item in sonOrderTypeSelect"
							:key="item.code"
							:label="item.description"
							:value="item.code"
						></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="投注IP">
					<el-input
						v-input="{ name: 'noEmpty' }"
						clearable
						v-model="queryData.ip"
						:placeholder="$t('common.please_enter')"
						maxLength="20"
						style="width: 200px"
					/>
				</el-form-item>
				<el-form-item label="投注金额" label-width="77px">
					<el-input
						v-model="queryData.betAmountStart"
						size="medium"
						:placeholder="$t('common.minimum')"
						style="width: 130px"
						maxLength="10"
						v-input="{ name: 'float', num: '2' }"
						name="betAmountStart"
						clearable
						@blur="
							handleAmount(
								queryData,
								1,
								'betAmountStart',
								'betAmountEnd',
								$t('member.check_min_tips')
							)
						"
					></el-input>
					-
					<el-input
						v-model="queryData.betAmountEnd"
						size="medium"
						:placeholder="$t('common.maximum')"
						style="width: 130px"
						maxLength="10"
						v-input="{ name: 'float', num: '2' }"
						name="betAmountEnd"
						clearable
						@blur="
							handleAmount(
								queryData,
								2,
								'betAmountStart',
								'betAmountEnd',
								$t('member.check_max_tips')
							)
						"
					></el-input>
				</el-form-item>
				<el-form-item label="输赢金额" label-width="77px">
					<el-input
						v-model="queryData.netAmountStart"
						size="medium"
						:placeholder="$t('common.minimum')"
						style="width: 130px"
						maxLength="10"
						v-input="{ name: 'onlyTwoNum' }"
						name="netAmountStart"
						clearable
						@blur="
							handleAmount(
								queryData,
								1,
								'netAmountStart',
								'netAmountEnd',
								$t('member.check_min_tips')
							)
						"
					></el-input>
					-
					<el-input
						v-model="queryData.netAmountEnd"
						size="medium"
						:placeholder="$t('common.maximum')"
						style="width: 130px"
						maxLength="10"
						v-input="{ name: 'onlyTwoNum' }"
						name="netAmountEnd"
						clearable
						@blur="
							handleAmount(
								queryData,
								2,
								'netAmountStart',
								'netAmountEnd',
								$t('member.check_max_tips')
							)
						"
					></el-input>
				</el-form-item>
				<el-form-item>
					<el-button
						type="primary"
						icon="el-icon-search"
						:disabled="loading"
						:loading="loading"
						size="medium"
						@click="search"
					>
						{{ $t('common.search') }}
					</el-button>
					<el-button
						icon="el-icon-refresh-left"
						:disabled="loading"
						size="medium"
						@click="reset"
					>
						{{ $t('common.reset') }}
					</el-button>
					<el-button
						v-if="hasPermission('90150031')"
						type="warning"
						size="medium"
						icon="el-icon-download"
						:disabled="exportloading"
						:loading="exportloading"
						@click="handleExport"
					>
						{{ $t('dxn.card_ables_list.export_excel') }}
					</el-button>
					<el-button
						v-if="hasPermission('90870095')"
						type="success"
						icon="el-icon-sort"
						size="medium"
						@click="showColumnSet"
					>
						{{ $t('common.row_set') }}
					</el-button>
				</el-form-item>
			</el-form>
		</template>
		<template slot="content">
			<el-table
				ref="refTable"
				@current-change="handleSelectRowHighlight"
				v-loading="loading"
				element-loading-spinner="el-icon-loading"
				border
				size="mini"
				:data="dataList"
				style="width: 100%"
				:max-height="tableHeight"
				highlight-current-row
				@sort-change="handleTableSort"
				show-summary
				:summary-method="
					(val) => handleRow(val, subSummary, totalSummary)
				"
			>
				<el-table-column
					type="index"
					:label="`${$t('dxn.game_rule.serial_number')}`"
					width="120"
					align="center"
				/>
				<el-table-column
					label="德州注单号"
					min-width="190"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{ scope.row.id }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.generatedId]"
					label="三方注单号"
					min-width="220"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{ scope.row.generatedId }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.playerName]"
					align="center"
					label="会员账号"
					width="150"
				>
					<template slot-scope="scope">
						{{ scope.row.playerName || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.userClubId]"
					label="会员所属俱乐部ID"
					min-width="125"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						<div
							v-if="scope.row.userClubId"
							class="text-link"
							@click="
								$router.push({
									path: '/dxn/clubManager/clubList',
									query: {
										clubId: scope.row.userClubId
									}
								})
							"
						>
							{{ scope.row.userClubId }}
						</div>
						<div v-else>-</div>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.parentOrderTypeDesc]"
					label="注单类型"
					min-width="150"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{ scope.row.parentOrderTypeDesc || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.betTypeDesc]"
					label="注单子类"
					min-width="150"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{ scope.row.betTypeDesc || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.handBeginDate]"
					label="投注时间"
					min-width="160"
					align="center"
					show-overflow-tooltip
					prop="handBeginDate"
					sortable="custom"
				>
					<template slot-scope="scope">
						{{ scope.row.handBeginDate || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.obBetStatus]"
					label="结算状态"
					min-width="150"
					align="center"
				>
					<template slot-scope="scope">
						<el-tag :type="obBetStatusStyle[scope.row.obBetStatus]">
							{{ obBetStatusText[scope.row.obBetStatus] || '-' }}
						</el-tag>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.handEndDate]"
					label="结算时间"
					min-width="160"
					align="center"
					show-overflow-tooltip
					prop="netAt"
					sortable="custom"
				>
					<template slot-scope="scope">
						{{ scope.row.handEndDate || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.tableCode]"
					label="牌桌ID"
					min-width="190"
					align="center"
				>
					<template slot-scope="scope">
						<div
							v-if="scope.row.tableCode"
							class="text-link"
							@click="
								handleJump({
									path:
										'/dxn/gameManager/cardTablesList/cardTablesBase',
									query: {
										tableId: scope.row.tableCode
									}
								})
							"
						>
							{{ scope.row.tableCode }}
						</div>
						<div v-else>-</div>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.tableName]"
					label="牌桌名称"
					min-width="150"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{ scope.row.tableName || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.gameType]"
					label="游戏名称"
					min-width="150"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						<span v-if="scope.row.gameType">
							{{ typeFilter(scope.row.gameType, 'gameType') }}
						</span>
						<span v-else>-</span>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.clubId]"
					label="牌桌所属俱乐部ID"
					min-width="125"
					align="center"
				>
					<template slot-scope="scope">
						<div
							v-if="scope.row.clubId"
							class="text-link"
							@click="
								handleJump({
									path: '/dxn/clubManager/clubList',
									query: {
										clubId: scope.row.clubId
									}
								})
							"
						>
							{{ scope.row.clubId }}
						</div>
						<div v-else>-</div>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.handId]"
					label="手牌ID"
					min-width="190"
					align="center"
				>
					<template slot-scope="scope">
						<div
							v-if="scope.row.handId"
							class="text-link"
							@click="
								handleJump({
									path: '/dxn/gameManager/gameList/gameBase',
									query: {
										handId: scope.row.handId
									}
								})
							"
						>
							{{ scope.row.handId }}
						</div>
						<div v-else>-</div>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.betAmount]"
					label="投注金额"
					min-width="150"
					align="center"
					show-overflow-tooltip
					prop="betAmount"
					sortable="custom"
				>
					<template slot-scope="scope">
						<span>
							{{
								handleNumber(
									scope.row.memberCurrency,
									scope.row.betAmount
								)
							}}
						</span>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.validBetAmount]"
					label="有效投注"
					min-width="150"
					align="center"
					show-overflow-tooltip
					prop="validBetAmount"
					sortable="custom"
				>
					<template slot-scope="scope">
						<span>
							{{
								handleNumber(
									scope.row.memberCurrency,
									scope.row.validBetAmount
								)
							}}
						</span>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.grossProfit]"
					label="未抽水输赢"
					min-width="150"
					align="center"
					show-overflow-tooltip
					prop="grossProfit"
					sortable="custom"
				>
					<template slot-scope="scope">
						<span v-if="scope.row.betType === 1">
							{{
								handleNumber(
									scope.row.memberCurrency,
									scope.row.grossProfit
								)
							}}
						</span>
						<span v-else>-</span>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.pumpContribution]"
					label="服务费贡献"
					min-width="150"
					align="center"
					show-overflow-tooltip
					prop="pumpContribution"
					sortable="custom"
				>
					<template slot-scope="scope">
						{{
							handleNumber(
								scope.row.memberCurrency,
								scope.row.pumpContribution
							)
						}}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.userHandFee]"
					label="手牌服务费"
					min-width="150"
					align="center"
					show-overflow-tooltip
					prop="userHandFee2"
					sortable="custom"
				>
					<template slot-scope="scope">
						<span v-if="scope.row.betType === 1">
							{{
								handleNumber(
									scope.row.memberCurrency,
									scope.row.userHandFee
								)
							}}
						</span>
						<span v-else>-</span>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.netAmount]"
					:key="columnSetKey"
					min-width="150"
					align="center"
					show-overflow-tooltip
					prop="netAmount"
					sortable="custom"
				>
					<template #header>
						<span>
							输赢金额
							<el-popover
								placement="top-start"
								width="auto"
								trigger="hover"
							>
								<div>俱乐部服务费类型注单：抽水后的输赢</div>
								<div>
									鱿鱼游戏类型注单：「中途站起」「触发风控」「鱿鱼独赢」可能导致输赢金额为0
								</div>
								<span slot="reference">
									<i class="el-icon-question"></i>
								</span>
							</el-popover>
						</span>
					</template>
					<template slot-scope="scope">
						<span>
							{{
								handleNumber(
									scope.row.memberCurrency,
									scope.row.netAmount
								)
							}}
						</span>
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.loginIp]"
					label="投注IP"
					min-width="130"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{ scope.row.loginIp || '-' }}
					</template>
				</el-table-column>
				<el-table-column
					v-if="tableColumnData[tableColumns.obDeviceType]"
					label="投注终端"
					min-width="150"
					align="center"
					show-overflow-tooltip
				>
					<template slot-scope="scope">
						{{
							typeFilter(
								scope.row.obDeviceType,
								'gameDeviceType'
							) || '-'
						}}
					</template>
				</el-table-column>
				<el-table-column
					align="center"
					label="操作"
					width="150"
					fixed="right"
				>
					<template slot-scope="scope">
						<el-button
							type="primary"
							size="medium"
							@click="
								showDetailBetSlip(scope.row.id, scope.$index)
							"
						>
							{{ $t('common.check_detail') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<el-pagination
				v-if="total"
				class="pageValue"
				background
				:current-page.sync="pageNum"
				layout="total, sizes,prev, pager, next, jumper"
				:page-size="pageSize"
				:page-sizes="$store.getters.pageSizes"
				:total="total"
				:pager-count="9"
				@current-change="handleCurrentChange"
				@size-change="handleSizeChange"
			/>
		</template>
		<InfoDrawer
			:isDialogVisible.sync="isDialogVisible"
			:detailLoading="detailLoading"
			:betSlipDetail="betSlipDetail"
			:recordLength="recordLength"
			:currentRecordIndex="currentRecordIndex"
			@getPrevAndNextBetSlip="getPrevAndNextBetSlip"
		/>
		<TableColumnSet
			v-if="colSettings.visible"
			:visible.sync="colSettings.visible"
			:dialogColumnData="dialogColumnData"
			:activityListField="activityListField"
			@submitColumnSet="submitColumnSet"
			@choiceColumnSet="choiceColumnSet"
		></TableColumnSet>
	</main-content>
</template>

<script>
import list from '@/mixins/list'
import InfoDrawer from './components/info'
import dayjs from 'dayjs'
import { routerNames } from '@/utils/consts'
import MainContent from '@/components/MainContent/index.vue'
import summaryList from './components/summaryList'
import tableScroll from '@/utils/tableScroll'
import { tableColumns } from './components/tableColumn'
import TableColumnSet from '@/components/Dxn/TableColumnSet'
import dxnMixin from '@/mixins/dxnMixin'

const initDate = () => [
	dayjs()
		.startOf('day')
		.subtract(6, 'day')
		.valueOf(),
	dayjs()
		.endOf('day')
		.valueOf()
]

export default {
	name: routerNames.betSlip,
	components: {
		TableColumnSet,
		MainContent,
		InfoDrawer
	},
	mixins: [list, summaryList, tableScroll, dxnMixin],
	data() {
		return {
			tableHeight: 480,
			otherDependenComponents: [],
			isDialogVisible: false,
			// activeIndex: 0,
			gameList: [],
			loading: false,
			exportloading: false,
			detailLoading: false,
			queryData: {
				clubId: '',
				userClubId: '',
				gameTypeList: [],
				handId: '',
				tableCode: '',
				id: '',
				userName: '',
				generatedId: '',
				dateTime: initDate(),
				settlementTime: initDate(),
				parentOrderTypeList: [],
				betTypeList: []
			},
			defaultBetSlipDetail: {
				id: undefined, // 德州注单号
				accountType: undefined, // 账号类型
				playerName: undefined, // 游戏账号
				netAmountSum: undefined, // 该类游戏总输赢
				clubId: undefined, // 俱乐部ID
				tableCode: undefined, // 牌桌号
				tableName: undefined, // 牌桌名称
				gameName: undefined, // 玩法名称
				gameType: undefined, // 游戏id
				handCode: undefined, // 手牌号
				betAmount: undefined, // 投注金额
				validBetAmount: undefined, // 有效投注
				netAmount: undefined, // 输赢金额
				loginIp: undefined, // 投注IP
				handBeginDate: undefined, // 投注时间
				obDeviceType: undefined, // 投注终端
				obBetStatus: undefined, // 结算状态
				handEndDate: undefined, // 结算时间
				memberCurrency: undefined, // 币种,
				pumpContribution: undefined, // 抽水贡献
				parentOrderType: undefined, // 注单类型
				betType: undefined, // 注单子类
				betTypeName: undefined // 注单类型名称
			},
			betSlipDetail: {},
			dataList: [],
			total: 0,
			recordLength: 0,
			currentRecordIndex: 0,
			allOrderTypeMap: new Map(),
			parentOrderTypeSelect: [],
			sonOrderTypeSelect: [],
			subSummary: {},
			totalSummary: {},
			obBetStatusStyle: {
				0: 'danger',
				1: 'success',
				2: 'danger'
			},
			obBetStatusText: {
				0: '未结算',
				1: '已结算',
				2: '不结算'
			},
			tableColumns
		}
	},
	computed: {
		gameTypes() {
			return this.globalDics.gameType || []
		}
		// isShowInfo() {
		// 	return Object.keys(this.rowData).length > 0
		// },
		// rowData() {
		// 	return this.list?.[this.activeIndex] || {}
		// },
		// disabledNext() {
		// 	return this.activeIndex >= this.betSlipIdArr.length - 1
		// },
		// disabledPrev() {
		// 	return this.activeIndex <= 0
		// }
	},
	watch: {
		'queryData.parentOrderTypeList': {
			handler(val) {
				this.queryData.betTypeList = []
				if (Array.isArray(val)) {
					if (val.length) {
						this.sonOrderTypeSelect = []
						val.forEach((item) => {
							this.sonOrderTypeSelect = this.sonOrderTypeSelect.concat(
								this.allOrderTypeMap.get(Number(item)) || []
							)
						})
					} else {
						this.sonOrderTypeSelect = this.allOrderTypeMap.get(0)
					}
				}
			}
		}
	},
	created() {
		this.initIndexDB('betSlip', this.activityListField)
		// this.getDxnGameManagerList()
		this.getGameRecordTypeSection()
	},
	methods: {
		getGameRecordTypeSection() {
			this.allOrderTypeMap = new Map()
			this.parentOrderTypeSelect = []
			this.sonOrderTypeSelect = []
			this.$api
				.getGameRecordTypeSectionBend()
				.then((res) => {
					if (res?.code === 200 && Array.isArray(res?.data)) {
						const allSonItem = []
						res.data.forEach((item) => {
							this.parentOrderTypeSelect.push({
								code: item.type,
								description: item.desc
							})
							const sonItem = []
							if (Array.isArray(item?.subList)) {
								item.subList.forEach((row) => {
									const rowItem = {
										code: row.type,
										description: row.desc
									}
									sonItem.push(rowItem)
									allSonItem.push(rowItem)
								})
							}
							this.allOrderTypeMap.set(item.type, sonItem)
						})
						this.sonOrderTypeSelect = [...allSonItem]
						this.allOrderTypeMap.set(0, allSonItem)
					}
				})
				.catch(() => {})
		},
		formatDate(dateTime) {
			if (dateTime) {
				return dayjs(dateTime).format('YYYY-MM-DD HH:mm:ss')
			}
			return ''
		},
		formatParams() {
			const [startTimeNum, endTimeNum] = this.queryData.dateTime || []
			const [settlementStartTimeNum, settlementEndTimeNum] =
				this.queryData.settlementTime || []

			const queryCondition = Object.assign({}, this.queryData, {
				betStartTime: this.formatDate(startTimeNum),
				betEndTime: this.formatDate(endTimeNum),
				settlementStartTime: this.formatDate(settlementStartTimeNum),
				settlementEndTime: this.formatDate(settlementEndTimeNum),
				dateTime: [],
				settlementTime: []
			})
			if (!queryCondition.gameTypeList?.length) {
				queryCondition.gameTypeList = undefined
			}
			if (!queryCondition.parentOrderTypeList?.length) {
				queryCondition.parentOrderTypeList = undefined
			}
			if (!queryCondition.betTypeList?.length) {
				queryCondition.betTypeList = undefined
			}
			delete queryCondition.dateTime
			delete queryCondition.settlementTime
			Object.keys(queryCondition).forEach((k) => {
				if (queryCondition[k] === '') {
					queryCondition[k] = undefined
				}
			})
			return {
				...this.pageParams,
				...queryCondition
			}
		},
		getDxnGameManagerList() {
			// this.$api
			// 	.getDxnGameManagerListBend()
			// 	.then((res) => {
			// 		this.gameList = res?.data?.gameConfigList || []
			// 	})
			// 	.catch((e) => {
			// 		console.error(e)
			// 	})
		},
		// 获取注单列表
		async loadData() {
			this.subSummary = {}
			this.totalSummary = {}
			this.dataList = []
			this.recordLength = 0
			this.loading = true
			const params = this.formatParams()
			await this.$api
				.betSlipQueryListBend(params)
				.then((ret) => {
					this.loading = false
					if (ret?.code === 200) {
						const { record = [], totalRecord, summary = [] } =
							ret.data || {}
						this.dataList = record
						this.total = totalRecord || 0
						this.recordLength = this.dataList.length
						this.subSummary = summary[0] || {}
						this.totalSummary = summary[1] || {}
					}
				})
				.catch(() => {
					this.loading = false
				})
		},
		// 获取上一条,下一条
		getPrevAndNextBetSlip(type) {
			// type 1上一条  2下一条
			const index =
				type === 1
					? this.currentRecordIndex - 1
					: this.currentRecordIndex + 1
			if (this.dataList[index]) {
				this.currentRecordIndex = index
				this.getBetSlipQueryDetail(this.dataList[index].id)
			}
		},
		// 显示详情
		showDetailBetSlip(betSlipId, index) {
			this.isDialogVisible = true
			this.currentRecordIndex = index
			this.getBetSlipQueryDetail(betSlipId)
		},
		// 获取注单详情
		async getBetSlipQueryDetail(betSlipId) {
			Object.assign(this.betSlipDetail, this.defaultBetSlipDetail)
			this.detailLoading = true
			await this.$api
				.betSlipQueryDetailBend({
					id: betSlipId
				})
				.then((res) => {
					if (res?.code === 200 && res?.data) {
						this.betSlipDetail = Object.assign({}, res.data)
					}
				})
				.catch(() => {})
				.finally(() => {
					this.detailLoading = false
				})
		},
		search() {
			this.clearTableSort()
			this.pageNum = 1
			this.loadData()
		},
		reset() {
			this.resetQueryData()
			this.pageNum = 1
			this.queryData.dateTime = initDate()
			this.queryData.settlementTime = initDate()
			this.loadData()
		},
		// 列表导出
		async handleExport() {
			this.exportloading = true
			const params = this.formatParams()
			this.deleteExportParams(params)
			this.exportExcelPublic({
				api: 'betSlipListExportBend',
				params
			})
				.catch(() => {})
				.finally(() => {
					this.exportloading = false
				})
		},
		handleJump(obj) {
			this.$router.push(obj)
		}
	}
}
</script>
<style lang="scss" scoped>
::v-deep .footer_count_row {
	min-height: 50px;
	height: 50%;
	display: flex;
	font-weight: 700;
	padding: 5px 0;
	align-items: center;
	flex-direction: column;
	justify-content: center;
}
::v-deep .footer_count_row_border {
	border-top: 1px solid #ebeef5;
}
.itemTip:after {
	font-size: 18px;
}
::v-deep .el-icon-question:after {
	font-size: 14px;
	margin-left: -2px;
}
</style>
